From af6b73a7e66d8ab7ca392cbdfda95b994fa50473 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 17 May 2023 12:46:22 -0400 Subject: [PATCH] push: Support --cleanup This option is not specific to sync, so it seemed it should be in either pull or push as well as sync. Since it does modify the remote, it seems better to have it in push; the modification of the local repo pulls in the direction of pull, but not hard enough. Maybe it would be better to have it in both? Sponsored-by: Luke Shumaker on Patreon --- Command/Sync.hs | 22 ++++++++++------------ doc/git-annex-push.mdwn | 24 +++++++++++++++++++----- doc/git-annex-sync.mdwn | 14 -------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/Command/Sync.hs b/Command/Sync.hs index ddd269fa54..59525befe8 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -151,15 +151,15 @@ optParser mode desc = SyncOptions ( long "not-only-annex" <> help "operate on git branches as well as annex" ) - <*> unlesssync False (switch + <*> unlessmode SyncMode False (switch ( long "commit" <> help "commit changes to git" )) - <*> unlesssync True (switch + <*> unlessmode SyncMode True (switch ( long "no-commit" <> help "avoid git commit" )) - <*> unlesssync Nothing (optional (strOption + <*> unlessmode SyncMode Nothing (optional (strOption ( long "message" <> short 'm' <> metavar "MSG" <> help "commit message" ))) @@ -190,24 +190,22 @@ optParser mode desc = SyncOptions <> help "transfer contents of annexed files in a given location" <> metavar paramPath )) - <*> unlesssync False (switch + <*> unlessmode PullMode False (switch ( long "cleanup" <> help "remove synced/ branches from previous sync" )) <*> optional parseAllOption - <*> case mode of - PushMode -> pure False - _ -> invertableSwitch "resolvemerge" True - ( help "do not automatically resolve merge conflicts" - ) + <*> unlessmode PushMode False (invertableSwitch "resolvemerge" True + ( help "do not automatically resolve merge conflicts" + )) <*> case mode of PushMode -> pure False _ -> parseUnrelatedHistoriesOption <*> pure mode where - unlesssync v a = case mode of - SyncMode -> a - _ -> pure v + unlessmode m v a + | mode /= m = a + | otherwise = pure v parseUnrelatedHistoriesOption :: Parser Bool parseUnrelatedHistoriesOption = diff --git a/doc/git-annex-push.mdwn b/doc/git-annex-push.mdwn index 36bebaf519..feb3622231 100644 --- a/doc/git-annex-push.mdwn +++ b/doc/git-annex-push.mdwn @@ -22,11 +22,11 @@ not normally update the remote's current branch with changes from the local repository. (Unless the remote is configured with receive.denyCurrentBranch=updateInstead.) -To make working with such non-bare remotes easier, this command pushes not only -local `master` to remote `master`, but also to remote `synced/master` (and -similar with other branches). When `git-annex pull` (or `git-annex sync`) -is later run on the remote, it will merge the `synced/` branches that -were pushed to it. +To make working with such non-bare remotes easier, this command pushes not +only local `master` to remote `master`, but also to remote `synced/master` +(and similar with other branches). When `git-annex pull` (or `git-annex +sync`) is later run on the remote, it will merge the `synced/` branches +that were pushed to it. Some special remotes allow exporting a tree of files to them, and this command can be used to push to those remotes as well @@ -108,6 +108,20 @@ See [[git-annex-preferred-content]](1). Setting this to "cpus" will run one job per CPU core. +* `--cleanup` + + Removes the local and remote `synced/` branches, which were created + and pushed by `git-annex push` or `git-annex sync`. This option + prevents all other activities. + + This can come in handy when you've pushed a change to remotes and now + want to reset your master branch back before that change. So you + run `git reset` and force-push the master branch to remotes, only + to find that the next `git annex merge` or `git annex pull` brings the + changes back. Why? Because the `synced/master` branch is hanging + around and still has the change in it. Cleaning up the `synced/` branches + prevents that problem. + * Also the [[git-annex-common-options]](1) can be used. # SEE ALSO diff --git a/doc/git-annex-sync.mdwn b/doc/git-annex-sync.mdwn index 96fcc17d54..e2023d8873 100644 --- a/doc/git-annex-sync.mdwn +++ b/doc/git-annex-sync.mdwn @@ -61,20 +61,6 @@ content by default. This may change in a future version of git-annex. When `remote..annex-sync` is set to false, pushing is disabled for that remote, and using `--push` will not enable it. -* `--cleanup` - - Removes the local and remote `synced/` branches, which were created - and pushed by `git-annex sync`. This option prevents all other syncing - activities. - - This can come in handy when you've synced a change to remotes and now - want to reset your master branch back before that change. So you - run `git reset` and force-push the master branch to remotes, only - to find that the next `git annex merge` or `git annex sync` brings the - changes back. Why? Because the `synced/master` branch is hanging - around and still has the change in it. Cleaning up the `synced/` branches - prevents that problem. - * Also all options supported by [[git-annex-pull]](1) and [[git-annex-push]](1) can be used. -- 2.30.2